package org.example.mallcommon.result;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * @author 韩先楚
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ReturnResult<T> implements Serializable {
    private static final long serialVersionUID = 1L;
    private int code;
    private String message;
    private T data;

    public static <T> ReturnResult<T> success() {
        return new ReturnResult<T>(200, "success", null);
    }
    public static <T> ReturnResult<T> success(T data) {
        return new ReturnResult<T>(200, "success", data);
    }

    public static <T> ReturnResult<T> success(String message, T data) {
        return new ReturnResult<T>(200, message, data);
    }

    public static <T> ReturnResult<T> error(String message)
    {
        return new ReturnResult<T>(500, message, null);
    }
    public static <T> ReturnResult<T> error(String message,T data)
    {
        return new ReturnResult<T>(500, message, data);
    }


}
